unit uPrintWin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Oracle, uutils, gnugettext, umainutils;

type
  TFrmPrintWin = class(TForm)
    lbl_Player: TLabel;
    img_Logo: TImage;
    Label1: TLabel;
    lbl_TicketType: TLabel;
    lbl_TournamentName: TLabel;
    lbl_TournamentDate: TLabel;
    Label3: TLabel;
    lbl_PlayerName: TLabel;
    lbl_Value: TLabel;
    lbl_TotalValue: TLabel;
    lbl_DateTime: TLabel;
    lbl_DateTimeValue: TLabel;
    Label4: TLabel;
    lbl_Table: TLabel;
    OracleQuery1: TOracleQuery;
    tmr_CloseForm: TTimer;
    Label5: TLabel;
    lbl_Seat: TLabel;
    Label2: TLabel;
    lbl_WinPos: TLabel;
    procedure tmr_CloseFormTimer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure SetData(TicketID: string; OraSession: TOracleSession);
    procedure PrintWin();
  end;

var
  FrmPrintWin: TFrmPrintWin;

implementation

uses uFrmMain;
{$R *.dfm}
{ TFrmTicket }

procedure TFrmPrintWin.FormCreate(Sender: TObject);
begin
  gnugettext.TranslateComponent(self);
end;

procedure TFrmPrintWin.PrintWin;
begin
  print();
end;

procedure TFrmPrintWin.SetData(TicketID: string; OraSession: TOracleSession);
begin
  if TicketID <> '-1' then
  begin
    OracleQuery1.Session := OraSession;
    // img_Logo.Picture := uutils.GetImage('select IMAGE, IMAGE_TYPE from SETTINGS where id=1', OraSession);
    img_Logo.Picture := FrmMain.img_LogoSettings.Picture;
    OracleQuery1.Close;

    OracleQuery1.SQL.Text :=
      'SELECT PL.NAME||'' ''||PL.SURNAME AS PLAYER_NAME,(SELECT SYSDATE FROM DUAL) AS NOW, TOU.EVENT_START,TA.NAME AS TABLE_NAME,PAY_VALUE, WIN_POSITION, TI.SEAT_NUM, TOU.NAME AS TOURNAMENT, TI.FEE, BUY_IN AS VALUE  FROM TICKETS TI'
      + ' JOIN PLAYERS PL ON TI.PLAYER_ID=PL.ID JOIN TOURNAMENTS TOU ON TOU.ID=TI.TOURNAMENT_ID JOIN TABLES TA ON TA.ID=TI.TABLE_ID WHERE TI.ID=' + TicketID;
    OracleQuery1.Execute;
    lbl_TicketType.Caption := 'WIN';
    if not OracleQuery1.eof then
    begin
      lbl_TournamentDate.Caption := OracleQuery1.Field('EVENT_START');
      lbl_TotalValue.Caption := VarToStr(OracleQuery1.Field('PAY_VALUE')) + ' ' + umainutils.Currency_Symbol;
      lbl_PlayerName.Caption := OracleQuery1.Field('PLAYER_NAME');
      lbl_TournamentName.Caption := OracleQuery1.Field('TOURNAMENT');
      lbl_Value.Caption := VarToStr(OracleQuery1.Field('PAY_VALUE')) + ' ' + umainutils.Currency_Symbol;
      lbl_DateTimeValue.Caption := OracleQuery1.Field('NOW');
      lbl_Table.Caption := OracleQuery1.Field('TABLE_NAME');
      lbl_Seat.Caption := OracleQuery1.Field('SEAT_NUM');
      lbl_WinPos.Caption := OracleQuery1.Field('WIN_POSITION');
      show();
      self.Repaint;
      tmr_CloseForm.Enabled := true;
    end;
  end;
end;

procedure TFrmPrintWin.tmr_CloseFormTimer(Sender: TObject);
begin
  tmr_CloseForm.Enabled := false;
  Close();
end;

end.
